package com.chj.zhongji.class01.test;

public class Code03_EatGrass {

	// n份青草放在一堆
	// 先手后手都决定聪明
	// string "先手" "后手"
	public static String winner1(int n) {
		if (n < 5) {
			return n == 0 || n == 2 ? "后手" : "先手";
		}

		int base = 1;
		while (n >= base) {
			if (winner1(n - base).equals("后手")) {
				return "先手";
			}

			if (base > n / 4) {
				break;
			}

			base *= 4;
		}

		return "后手";
	}

	public static String winner2(int n) {
		if (n % 5 == 0 || n % 5 == 2) {
			return "后手";
		} else {
			return "先手";
		}
	}

	public static void main(String[] args) {
		for (int i = 0; i <= 50; i++) {
			System.out.println(i + " : " + winner1(i));
		}
	}

}
